home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
476-500
/
disk_487
/
assignx
/
assignx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
3KB
|
139 lines
/************************************************************************/
/* EasyRequest trapper - deals with requests for nonexistant volumes */
/* V1.1, by Steve Tibbett */
/************************************************************************/
#include <Stdio.h>
#include <libraries/gadtools.h>
#include <intuition/intuition.h>
#include <proto/gadtools.h>
#include <proto/asl.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <dos/dos.h>
#include <exec/memory.h>
#include <string.h>
#include <ctype.h>
struct Library *IntuitionBase;
struct Library *AslBase;
struct Remember *Remember;
void MemCleanup(void) { }
struct AbortedList
{
struct AbortedList *Next;
char Name[1];
} *AbortedList;
void *OrigFunc;
char AXVersion[] = "$VER: AssignX 1.2 (22-Apr-91) by Steve Tibbett";
/************************************************************************/
/* The new "EasyRequest" */
/************************************************************************/
int __saveds __interrupt __asm
NewFunc(register __a0 struct Window *Win, register __a1 struct EasyStruct *EZ,
register __a2 ULONG *idcmp, register __a3 ULONG *args)
{
int Res;
int Mine=0;
if (EZ->es_TextFormat[0]=='%' && EZ->es_TextFormat[1]=='s' && args && args[0] && (strcmp((char *)args[0], "Please insert volume")==0))
{
struct AbortedList *AL=AbortedList;
while (AL)
{
if (stricmp((char *)AL->Name, (char *)args[1])==0)
return(0);
AL=AL->Next;
};
EZ->es_GadgetFormat="Retry|Assign...|Mount|Deny|Cancel";
Mine=1;
};
Res=MyFunc(Win, EZ, idcmp, args);
if (Mine)
{
switch (Res)
{
case 2:
{
BPTR AsnLock;
char buff[80];
char *FullName;
struct FileRequester *FR;
strcpy(buff, "Assignment for '");
strcat(buff, (char *)args[1]);
strcat(buff, "':");
FR=(struct FileRequester *)AslFileRequest(Win, buff, "RAM:", "", 0, &FullName);
if (FR) {
AsnLock=Lock(FullName, ACCESS_READ);
if (AsnLock)
AssignLock((char *)args[1], AsnLock);
FreeVec(FullName);
FreeFileRequest(FR);
};
return(1);
break;
};
case 3:
{
char buff[128];
strcpy(buff, "Mount >NIL: <NIL: ");
strcat(buff, args[1]);
strcat(buff, ":");
System(buff,0);
return(1);
};
case 4:
{
struct AbortedList *AL=(struct AbortedList *)AllocRemember(&Remember, strlen((char *)args[1])+sizeof(struct AbortedList)+2, MEMF_CLEAR);
if (AL) {
strcpy(AL->Name, (char *)args[1]);
AL->Next=AbortedList;
AbortedList=AL;
};
};
};
};
return(Res);
}
main()
{
void *OurVec;
IntuitionBase=OpenLibrary("intuition.library", 36);
AslBase=OpenLibrary("asl.library", 36);
if (IntuitionBase==0 || AslBase==0)
return(10);
OrigFunc=SetFunction(IntuitionBase, -0x24c, NewFunc);
if (OrigFunc==0)
return(15);
Wait(SIGBREAKF_CTRL_C);
OurVec=SetFunction(IntuitionBase, -0x24c, OrigFunc);
if (OurVec!=NewFunc)
EasyRequester(NULL, "AssignX Request", "Error removing wedge!\nReboot soon!", "Okay");
FreeRemember(&Remember, TRUE);
CloseLibrary(IntuitionBase);
CloseLibrary(AslBase);
return(0);
}